package org.richin.collection.util;

import java.util.HashMap;

/**
 * Shortcut Map by extending HashMap.
 * You can use it as below:
 * map.put("country", "China", "city", "wuhan");
 * or
 * new QuickMap("country", "China", "city", "wuhan")
 * or
 * map.add("country", "China").add("city", "wuhan");
 * 
 * ablow is the same as old style:
 * map.put("country", "Chian")
 * map.put("city", "wuhan");
 * 
 * @author lichun
 *
 */
public class QuickMap extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;

	public QuickMap() {
	}

	/**
	 * 
	 * @param args
	 */
	public QuickMap(Object... args) {
		put(args);
	}

	/**
	 * shortcut method for put key-value in map.
	 * 
	 * @param args key-vlaue objects, the firt is key , the second is
	 * value, and so on.  
	 * @date Apr 22, 2009
	 * @auther Lichun
	 * @see
	 */
	public void put(Object... args) {
		for (int i = 1; i < args.length; i += 2) {
			put(String.valueOf(args[i - 1]), args[i]);
		}
	}

	/**
	 * shortcut method 
	 * @param key key in map
	 * @param value value in map
	 * @return a QuickMap instance , you can add next key-value.
	 * @date Apr 22, 2009
	 * @auther Lichun
	 * @see
	 */
	public QuickMap add(String key, Object value) {
		this.put(key, value);

		return this;
	}
	public static void main(String[] args) {
		
	}
}
